// 用于生成和解析token
var jwt = require('jsonwebtoken');
var signkey = 'mes_qdhd_mobile_xhykjyxgs';
var setToken = function (user_name, user_id) {
    return new Promise((resolve,reject)=>{
       const token = jwt.sign({
         name:user_name,
         _id:user_id
       },signkey,{ expiresIn:'12h' });
       resolve(token);
     })

}
var verToken = function (token) {
  return new Promise((resolve,reject)=>{
    var info = jwt.verify(token.split(' ')[1],signkey);
    resolve(info);
  })
}
module.exports = {
    setToken,
    verToken
}